package com.smcdd.cdb.dbo.cdb_dbo.network;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by Jeremylee on 2017/6/6.
 */

public class HttpU {

    public static RequestBody getRequestBody(Map<String, Object> map) {
        JSONObject jsonObject = new JSONObject();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            try {
                jsonObject.put(entry.getKey(), entry.getValue());
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return RequestBody.create(MediaType.parse("Content-Type, application/json"), jsonObject.toString());
    }
}
